home *** CD-ROM | disk | FTP | other *** search
- #
- # lmatch.test
- #
- # Tests for the lmatch command.
- #---------------------------------------------------------------------------
- # Copyright 1993 Karl Lehenbauer and Mark Diekhans.
- #
- # Permission to use, copy, modify, and distribute this software and its
- # documentation for any purpose and without fee is hereby granted, provided
- # that the above copyright notice appear in all copies. Karl Lehenbauer and
- # Mark Diekhans make no representations about the suitability of this
- # software for any purpose. It is provided "as is" without express or
- # implied warranty.
- #
- # Based on test code that is
- # Copyright (c) 1991-1993 The Regents of the University of California.
- # All rights reserved.
- #
- # Permission is hereby granted, without written agreement and without
- # license or royalty fees, to use, copy, modify, and distribute this
- # software and its documentation for any purpose, provided that the
- # above copyright notice and the following two paragraphs appear in
- # all copies of this software.
- #
- # IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
- # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
- # OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
- # CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- #
- # THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- # AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- # ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
- # PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- #
-
- if {[info procs test] != "test"} then {source testlib.tcl}
-
- set x {abcd bbcd 123 234 345 445}
-
- Test lmatch-1.1 {lmatch command} {
- lmatch $x 123
- } 0 "123"
-
- Test lmatch-1.2 {lmatch command} {
- lmatch $x 3456
- } 0 ""
-
- Test lmatch-1.3 {lmatch command} {
- lmatch $x *5
- } 0 "345 445"
-
- Test lmatch-1.4 {lmatch command} {
- lmatch $x *bc*
- } 0 "abcd bbcd"
-
- Test lmatch-2.1 {search modes} {
- lmatch -exact {xyz bbcc *bc*} *bc*
- } 0 "*bc*"
-
- Test lmatch-2.2 {search modes} {
- lmatch -exact {b.x ^bc xy bcx ^bc} ^bc
- } 0 "^bc ^bc"
-
- Test lmatch-2.3 {search modes} {
- lmatch -regexp {xyz bbcc *bc*} *bc*
- } 1 {couldn't compile regular expression pattern: ?+* follows nothing}
-
- Test lmatch-2.4 {search modes} {
- lmatch -regexp {b.x ^bc xy bcx bca} ^bc
- } 0 "bcx bca"
-
- Test lmatch-2.5 {search modes} {
- lmatch -glob {xyz bbcc *bc* abcd} *bc*
- } 0 "bbcc *bc* abcd"
-
- Test lmatch-2.6 {search modes} {
- lmatch -glob {b.x ^bc xy bcx} ^bc
- } 0 "^bc"
-
- Test lmatch-2.7 {search modes} {
- lmatch -glib {b.x bx xy bcx} b.x
- } 1 {bad search mode "-glib": must be -exact, -glob, or -regexp}
-
- Test lmatch-3.1 {lmatch errors} {
- lmatch
- } 1 {wrong # args: should be "lmatch ?mode? list pattern"}
-
- Test lmatch-3.2 {lmatch errors} {
- lmatch a
- } 1 {wrong # args: should be "lmatch ?mode? list pattern"}
-
- Test lmatch-3.3 {lmatch errors} {
- lmatch a b c
- } 1 {bad search mode "a": must be -exact, -glob, or -regexp}
-
- Test lmatch-3.4 {lmatch errors} {
- lmatch a b c d
- } 1 {wrong # args: should be "lmatch ?mode? list pattern"}
-
- Test lmatch-3.5 {lmatch errors} {
- lmatch "\{" b
- } 1 {unmatched open brace in list}
-
-